MarkLogic Server 11.0 Product Documentation
POST /manage/v2/databases/{id|name}/partitions

Summary

Add a range or query partition to the database.

URL Parameters
format The format of the data in the request body. Can be either json, or xml. Use this parameter to override the Content-type header.
Request Headers
Accept The expected MIME type of the response. If the format parameter is present, it takes precedence over the Accept header.
Content-type The MIME type of the data in the request body. If the format parameter is present, it takes precedence over this header. Accepted values: application/xml, application/json.
Response Headers
Location A reference to the newly created partition with which you can construct a URL for the resource that is usable in subsequent requests. For example, /manage/v2/databases/your-db-id/partitions/your-partition-name.
Content-type The MIME type of the data in the response body. Depending upon the value of the format parameter or Accept header, one of application/xml, application/json, or text/html.

Response

Upon success, MarkLogic server returns status code 201 (Created). If the payload is malformed or the partition already exists, a status code of 400 (Bad Request) is returned. A status code of 401 (Unauthorized) is returned if the user does not have the necessary privileges.

Required Privileges

This operation requires the manage-admin role, or the following privilege:

http://marklogic.com/xdmp/privileges/manage-admin

Usage Notes

Before creating a range partition, you must first define the partition key and set the assignment policy of the database to 'range'. For details, see Configuring a Database with Range Partitions in the Administrator's Guide.

The range partition configuration in the POST body must contain at least the partition-name, lower-bound, upper-bound, forests-per-host, and host elements or keys. For more details and a list of available options, see tieredstorage:range-partition-create.

Before creating a query partition, you must first set assignment policy for the database to 'query'. For details, see Configuring a Database with Query Partitions in the Administrator's Guide.

The query partition configuration in the POST body must contain at least the partition-name, partition-number, forests-per-host, and host elements or keys. For more details and a list of available options, see tieredstorage:query-partition-create.

The structure of the data in the request body is as follows:

partition-name

Name of the partition.

partition-number

upper-bound

The upper bound of the range on the forest.

lower-bound

The lower bound of the range on the forest.

forests-per-host

Number of forests to distribute per host.

hosts

A list of hosts.

This is a complex structure with the following children:

host

A host name or id.

replicas

Number of forests to allocate to each host for partition creation.

data-directory

The optional public directory for forests.

large-data-directory

The optional directory for large objects in a forest.

fast-data-directory

The optional smaller but faster directory for forests.

options

A list of options.

This is a complex structure with the following children:

option

An option.

Example


The following creates a range partition.

$ cat range-partition.xml
==> 
<partition xmlns="http://marklogic.com/manage">
  <partition-name>2011</partition-name>
  <lower-bound>2011-01-01</lower-bound>
  <upper-bound>2011-12-31</upper-bound>
  <forests-per-host>1</forests-per-host>
  <hosts>
     <host>host-1</host>
     <host>host-2</host>
  </hosts>
  <data-directory></data-directory>
  <large-data-directory></large-data-directory>
  <fast-data-directory></fast-data-directory>
  <options>
    <option>failover=none</option>
  </options>
</partition>

$ curl --anyauth --user user:password -X POST -d @./range-partition.xml \
    -i -H "Content-type: application/xml" \
    http://localhost:8002/manage/v2/databases/example-db/partitions

==> A new range partition named "2011" is created for example-db.
    Forests 2011-0001 and 2011-0002 are created, one on each
    named host. MarkLogic Server responds with headers similar to
    the following.

HTTP/1.1 201 Created
Cache-Control: no-cache
Expires: -1
Location: /manage/v2/databases/13475778675412262560/partitions/2011
Server: MarkLogic
Set-Cookie: SessionID=d647d71d2ffc55d6; path=/
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
    

Example


$ cat range-partition.json
==> 
{
  "partition-name": "2012",
  "lower-bound": "2012-01-01",
  "upper-bound": "2012-12-31",
  "forests-per-host": 1,
  "host": [ "host-1", "host-2" ],
  "option": [ "failover=none" ]
}

$ curl --anyauth --user user:passowrd -X POST -d @./range-partition.json \
    -i -H "Content-type: application/json" 
    http://localhost:8002/manage/v2/databases/example-db/partitions

==> A new range partition named "2012" is created for example-db.
    Forests 2012-0001 and 2012-0002 are created, one on each
    named host. MarkLogic Server responds with headers similar to
    the following.

HTTP/1.1 201 Created
Cache-Control: no-cache
Expires: -1
Location: /manage/v2/databases/13475778675412262560/partitions/2012
Server: MarkLogic
Set-Cookie: SessionID=53f1ed9b18ed7196; path=/
Content-Length: 0
Connection: Keep-Alive
Keep-Alive: timeout=5
    

Example


The following creates a query partition.

curl -X POST --anyauth --user admin:admin -H "Content-type: application/json" \
-d '{
  "partition-name": "tier1",
  "partition-number": "1",
  "forests-per-host": 2,
  "host": [ "gordon-1.marklogic.com" ],
  "option": [ "failover=none" ]
}' \
http://gordon-1:8002/manage/v2/databases/db1/partitions

==> A new query partition, named "tier1", is created for db1.
    Forests tier1-0001 and tier1-0002 are created on host,
    "gordon-1.marklogic.com". 
 
    
Powered by MarkLogic Server | Terms of Use | Privacy Policy